/**
 * 
 */
package niuke;

import java.util.Scanner;

/**
 * @author zhongfang
 *
 */
public class JailBreak {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int M=scanner.nextInt();
		int N=scanner.nextInt();
        if(M==0||N<=1){
        	System.out.println(0);
        	return;
        }
        long success =0;
        long unsuccess=M;
        long circleTime = N-1;
        while (circleTime>0){
            success = (success*M+unsuccess)%100003;
            unsuccess = (unsuccess*(M-1))%100003;
            circleTime--;
        }

        System.out.println(success);
	}

}
